<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ page import="global.Constants" %>
<% String contextPath=request.getContextPath(); %>
<html>
	<head>
			<script type="text/javascript" src="<%=contextPath %>/js/amountNum.js"></script>
			<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
			<script type="text/javascript">
				$(document).ready(function() {

					var savingSubmitGrid = new Ext.FormPanel({
						labelAlign: 'top',
						frame: true,
						title: '存款提交',
						renderTo: 'savingSubmitDiv',
						//bodyStyle:'padding:5px 5px 0',
						//width: 600,
						height: 500,
						items: [{
							layout: 'column',
							items: [{
								columnWidth: 1,
								layout: 'form',
								items: [{
									xtype: 'label',
									id: 'atteTitle',
									text: '注意：',
									cls: 'atteTitle',
									anchor: '95%'
								},{
									xtype: 'label',
									id: 'atteDetail1',
									text: '*为了确保您的存款能够及时到账，请在存款时，将金额的零头修改为红色存款编号对应的数字，谢谢合作！',
									cls: 'atteDetail',
									anchor: '95%'
								},{
									xtype: 'label',
									id: 'atteDetail2',
									text: '填写格式：如您的编号为28，需要存款500元时，请在存款时存入人民币528元，或是502.8元，再或是500.28元。',
									cls: 'atteDetail',
									anchor: '95%'
								},{
									layout:'column',
	            					items: [//共有2列
									{
										xtype: 'label',
										text: '存款编号：',
										cls: 'atteDetail',
										anchor: '95%'
									},{
										xtype: 'label',
										id: 'amountSerial',
										text: '17',
										cls: 'atteTitle',
										anchor: '95%'
									}]
								},{
									xtype: 'numberfield',
									fieldLabel: '金    额',
									emptyText : '请输入要存入的金额数目', 
									id: 'amount',
									cls: 'inputAmount',
									anchor: '95%'
								},
								{
									xtype: 'numberfield',
									fieldLabel: '金额确认',
									emptyText : '请再一次输入要存入的金额数目', 
									id: 'amountConfirm',
									cls: 'inputAmount',
									anchor: '95%'
								},
								{
									xtype: 'radiogroup',  
									fieldLabel: '支付方式',  
									id: 'payModel', 
									items: [          
										{boxLabel: '中国农业银行（刘军）(6228480058024461871)',id:'abc' , name: 'rb-auto', inputValue: 1},
										{boxLabel: '中国工商银行（刘军）(6222023202050348894)',id:'icbc', name: 'rb-auto', inputValue: 2},
										{boxLabel: '中国建设银行（刘军）(6217002870009828334)',id:'ccb', name: 'rb-auto', inputValue: 3},
										{boxLabel: '财付通(1000)',id:'tenpay', name: 'rb-auto', inputValue: 4}
									]
								}]
							}]
						},
						{
							xtype: 'textarea',
							id: 'remark',
							fieldLabel: '备注',
							anchor: '98%'
						},
						{
							xtype: 'label',
							id: 'tips',
							text: '*请填入存款地址，流水号，存款时间等详细信息。',
							cls: 'atteDetail',
							anchor: '95%'
						}],
				
						buttons: [{
							text: '确认存款'
						},
						{
							text: '取    消'
						}]
					});
				
				});
				
				//针对NumberField做金额的格式化
				if (Ext.form.NumberField) {
					Ext.apply(Ext.form.NumberField.prototype, {
						decimalPrecision: 2,
						// allowNegative :false,
						allowDecimals: true
						// allowBlank : false
						,
						cls: 'numReadOnly'
						// private
						,
						FormatComma: true
						// private
						,
						initEvents: function() {
							Ext.form.NumberField.superclass.initEvents.call(this);
							var allowed = this.baseChars + '';
							if (this.allowDecimals) {
								allowed += this.decimalSeparator;
							}
							if (this.FormatComma) {
								allowed += ",";
							}
							if (this.allowNegative) {
								allowed += "-";
							}
							this.stripCharsRe = new RegExp('[^' + allowed + ']', 'gi');
							var keyPress = function(e) {
								var k = e.getKey();
								if (!Ext.isIE && (e.isSpecialKey() || k == e.BACKSPACE || k == e.DELETE)) {
									return;
								}
								var c = e.getCharCode();
								if (allowed.indexOf(String.fromCharCode(c)) === -1) {
									e.stopEvent();
								}
							};
							this.el.on("keypress", keyPress, this);
						},
						// private
						validateValue: function(value) {
							var tmpvalue = this.removeCommas(String(value));
							if (!Ext.form.NumberField.superclass.validateValue.call(this, tmpvalue)) {
								return false;
							}
							if (value.length < 1) { 
								return true;
							}
							if (this.FormatComma) {
								value = this.removeCommas(String(value));
							}
							value = String(value).replace(this.decimalSeparator, ".");
							if (isNaN(value)) {
								this.markInvalid(String.format(this.nanText, value));
								return false;
				
							}
							var num = this.parseValue(value);
							if (num < this.minValue) {
								this.markInvalid(String.format(this.minText, this.minValue));
								return false;
							}
							if (num > this.maxValue) {
								this.markInvalid(String.format(this.maxText, this.maxValue));
								return false;
							}
							return true;
						},
						fixPrecision: function(value) {
							var nan = isNaN(value);
							if (!this.allowDecimals || this.decimalPrecision == -1 || nan || !value) {
								return nan ? '': value;
							}
							return parseFloat(parseFloat(value).toFixed(this.decimalPrecision));
						},
				
						setValue: function(v) {
							v = typeof v == 'number' ? v: (String(this.removeCommas(v)).replace(this.decimalSeparator, "."));
							v = isNaN(v) ? '': String(v).replace(".", this.decimalSeparator);
							if (String(v).length > 0) v = parseFloat(v).toFixed(this.decimalPrecision);
							Ext.form.NumberField.superclass.setValue.call(this, v);
							if (this.FormatComma && String(v).length > 0) {
								v = this.addCommas(v);
								Ext.form.NumberField.superclass.setRawValue.call(this, v);
							}
						},
						parseValue: function(value) {
							if (this.FormatComma) value = this.removeCommas(String(value));
							value = parseFloat(String(value).replace(this.decimalSeparator, "."));
				
							return isNaN(value) ? '': value;
						},
						beforeBlur: function() {
							var v = this.parseValue(this.getRawValue());
				
							if (String(v).trim().length > 0) {
								this.setValue(this.fixPrecision(v));
				
							}
						}
				
						,
						addCommas: function(nStr) {
				
							nStr += '';
							if (nStr.length == 0) return '';
							x = nStr.split('.');
							x1 = x[0];
							x2 = x.length > 1 ? '.' + x[1] : '';
							var rgx = /(\d+)(\d{3})/;
							while (rgx.test(x1)) {
								x1 = x1.replace(rgx, '$1' + ',' + '$2');
							}
							return x1 + x2;
				
						},
						removeCommas: function(nStr) {
							nStr = nStr + '';
							var r = /(\,)/;
							while (r.test(nStr)) {
								nStr = nStr.replace(r, '');
							}
							return nStr;
						}
					});
				}
				
			</script>
	</head>
	<body>
		<div id="savingSubmitDiv">
			<div id="tenpayDiv">
			</div>
		</div>
	</body>

</html>